<div class="items index">
	<h2><?php __($this->Html->link('Items', array('action' => 'index')));?></h2>

        

        <div class="filter">
	<?php
		echo $this->Form->create('Item', array(
			'url' => array_merge(array('action' => 'index'), $this->params['pass'])
			));
		echo $this->Form->input('name', array('div' => false, 'empty' => true, 'label' => false));
		echo $this->Form->submit(__('Search', true), array('div' => false));
		echo $this->Form->end();
	?>
	</div>

	<table cellpadding="0" cellspacing="0">
	<tr>
			<th><?php echo $this->Paginator->sort('name');?></th>
			<th><?php echo $this->Paginator->sort('type_id');?></th>
			<th><?php echo $this->Paginator->sort('price');?></th>
                        <th><?php echo $this->Paginator->sort('weight');?></th>
	</tr>
	<?php
	$i = 0;
	foreach ($items as $item):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
                <td><b><?php echo $this->Html->link($item['Item']['name'],
                                                        array('action' => 'view', $item['Item']['id']),
                                                        array('escape' => false)); ?>&nbsp;</b><br>
                        <?php echo $this->Html->link($html->image('uploads' . DS . 'images' . DS . 'thumb.small.' . $item['Item']['image_filename']),
                                                        array('action' => 'view', $item['Item']['id']),
                                                        array('escape' => false)); ?>&nbsp
                </td>
                <td><?php echo $item['Type']['name']; ?>&nbsp;</td>
                <td><?php echo '$'.$item['Item']['price']; ?>&nbsp;</td>
                <td><?php echo $item['Item']['weight'].'g'; ?>&nbsp;</td>
		<td class="actions">
			<?php echo $this->Html->link(__('Add to cart', true), array('action' => 'view', $item['Item']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
	));
	?>	</p>

	<div class="paging">
		<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>
</div>
<div class="actions">
	<h3><?php if ($admin)  __('Actions'); ?></h3>
	<ul>
		<li><?php if ($admin) echo $this->Html->link(__('New Item', true), array('action' => 'add')); ?></li>
		<li><?php if ($admin) echo $this->Html->link(__('List Types', true), array('controller' => 'types', 'action' => 'index')); ?> </li>
		<li><?php if ($admin) echo $this->Html->link(__('New Type', true), array('controller' => 'types', 'action' => 'add')); ?> </li>
	</ul>

        <h3><?php __($this->Html->link('Categories', array('action' => 'index')));?></h3>
	<table cellpadding="0" cellspacing="0">
	<?php
	$i = 0;
	foreach ($types as $type):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
                <td><?php echo $this->Html->link($type['Type']['name'], array_merge(array('action' => 'index'), array('type_id' => $type['Type']['id']))); ?></td>
	</tr>
        <?php endforeach; ?>
	</table>
</div>